package UIlayer;
import java.util.Scanner;

/**
 * Write a description of class Main here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MainUI
{
    private Scanner input;
    private VareUI vareUI;
    private OrdreUI ordreUI;
    private KundeUI kundeUI;

    /**
     * Constructor for objects of class Main
     */
    @SuppressWarnings("static-access")
	public MainUI()
    {
        vareUI = vareUI.getInstance();
        ordreUI = ordreUI.getInstance();
        kundeUI = kundeUI.getInstance();
        input = new Scanner(System.in);
    }
    
    /**
     * Starter UI'en
     */
    public static void main()
    {
        MainUI UI = new MainUI();
        UI.mainMenu();
    }
    
    /**
     * Menuen hvorfra man kan vælge hvor man går hen
     */
    public void mainMenu()
    {
        boolean exit = false;
        int i = 0;
        while(!exit)
        {
            System.out.println("\n\n1. Ordre menu \n2. Vare menu \n3. Kunde menu \n");
            switch(getInt()){
                case -1:
                if(i > 10)
                {
                    fuckoff();
                    exit = true;
                    break;
                }
                System.out.println("enter whole number please ");
                i++;
                break;
                case 1:
                ordreUI.ordreMenu();
                break;
                case 2:
                vareUI.vareMenu();
                break;
                case 3:
                kundeUI.kundeMenu();
                break;
                default:
                System.out.println("bad choice");
                exit = true;
                break;
            }
        }
    }

    /**
     * Returnere den næste int der indtastes, hvis det ikke er en int returner den -1
     */
    private int getInt()
    {
        int choice = -1;
        if(input.hasNextInt())
        {
            choice = input.nextInt();
        }
        else
        {
            @SuppressWarnings("unused")
			String whatever = input.next();
        }
        System.out.println();
        return choice;
    }

    /**
     * En fin metode til de narhatte der er træls
     */
    private void fuckoff()
    {
        System.out.println("now look at what you did...");
        try
        {
            Thread.sleep(500);
        }
        catch(InterruptedException e){}
        for(int i = 0; i < 100; i++)
        {
            System.out.println("just enter a fucking NUMBER!");
            try
            {
                Thread.sleep(100);
            }
            catch(InterruptedException e){}
        }
    }
}